import React, { useEffect } from "react";
import RouterView from "../../route/RouteView";

const NavList = [
  {
    path: "/index/home",
    icon: "icon-shouye",
    icon_active: "icon-shouye-copy",
    title: "首页",
  },
  {
    path: "/index/room",
    icon: "icon-xinfang_dituzhaofang",
    icon_active: "icon-xinfang_dituzhaofang-copy",
    title: "找房",
  },
  {
    path: "/index/my",
    icon: "icon-wode",
    icon_active: "icon-wode-copy",
    title: "我的",
  },
];
export default function Index(props: any) {
  const { children } = props;
  const { pathname, state } = props.location;

  return (
    <div className="warp">
      <main>
        <RouterView routerList={children} />
      </main>
      {state?.rentType === undefined ? (
        <footer>
          {NavList.map((v) => {
            return (
              <div key={v.path} onClick={() => props.history.push(v.path)}>
                <i
                  className={
                    pathname === v.path
                      ? `iconfont ${v.icon_active} active`
                      : `iconfont ${v.icon}`
                  }
                ></i>
                <span className={pathname === v.path ? `active` : ``}>
                  {v.title}
                </span>
              </div>
            );
          })}
        </footer>
      ) : (
        ""
      )}
    </div>
  );
}
